package com.ruoyi.water.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.water.domain.MyShortFlowingWater;
import com.ruoyi.water.service.IMyShortFlowingWaterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 短剧消费流水表Controller
 * 
 * @author zunzun
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/water/water")
public class MyShortFlowingWaterController extends BaseController
{
    @Autowired
    private IMyShortFlowingWaterService myShortFlowingWaterService;

    /**
     * 查询短剧消费流水表列表
     */
    @PreAuthorize("@ss.hasPermi('water:water:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyShortFlowingWater myShortFlowingWater)
    {
        startPage();
        List<MyShortFlowingWater> list = myShortFlowingWaterService.selectMyShortFlowingWaterList(myShortFlowingWater);
        return getDataTable(list);
    }

    /**
     * 导出短剧消费流水表列表
     */
    @PreAuthorize("@ss.hasPermi('water:water:export')")
    @Log(title = "短剧消费流水表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyShortFlowingWater myShortFlowingWater)
    {
        List<MyShortFlowingWater> list = myShortFlowingWaterService.selectMyShortFlowingWaterList(myShortFlowingWater);
        ExcelUtil<MyShortFlowingWater> util = new ExcelUtil<MyShortFlowingWater>(MyShortFlowingWater.class);
        util.exportExcel(response, list, "短剧消费流水表数据");
    }

    /**
     * 获取短剧消费流水表详细信息
     */
    @PreAuthorize("@ss.hasPermi('water:water:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(myShortFlowingWaterService.selectMyShortFlowingWaterById(id));
    }

    /**
     * 新增短剧消费流水表
     */
    @PreAuthorize("@ss.hasPermi('water:water:add')")
    @Log(title = "短剧消费流水表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyShortFlowingWater myShortFlowingWater)
    {
        return toAjax(myShortFlowingWaterService.insertMyShortFlowingWater(myShortFlowingWater));
    }

    /**
     * 修改短剧消费流水表
     */
    @PreAuthorize("@ss.hasPermi('water:water:edit')")
    @Log(title = "短剧消费流水表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyShortFlowingWater myShortFlowingWater)
    {
        return toAjax(myShortFlowingWaterService.updateMyShortFlowingWater(myShortFlowingWater));
    }

    /**
     * 删除短剧消费流水表
     */
    @PreAuthorize("@ss.hasPermi('water:water:remove')")
    @Log(title = "短剧消费流水表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(myShortFlowingWaterService.deleteMyShortFlowingWaterByIds(ids));
    }
}
